Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support Mirrored mode networking for wsl2 #879

Closed
wants to merge 2 commits into from
Closed

support Mirrored mode networking for wsl2 #879

wants to merge 2 commits into from

Conversation

hellototoro
Copy link

Description
Mirrored mode networking is a new network mode of wsl2. In this mode, we can use localhost accessing Windows networking apps from Linux.

When the following is written in the .wslconfig file, the wsl2 is switched to Mirrored mode

# Enable experimental features
[experimental]
# Network
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true

Related Issues
maybe #759

Affected Packages

  • webots_ros2_driver

Tasks
Add the list of tasks of this PR.

  • support Mirrored mode networking for wsl2
  • rename a few function

Additional context

Copy link
Member

@omichel omichel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this contribution.
However, I would request a couple of changes.

def controller_protocol():
protocol = 'tcp' if (has_shared_folder() or is_wsl()) else 'ipc'
return protocol


def controller_ip_address():
ip_address = get_host_ip() if has_shared_folder() else get_wsl_ip_address()
ip_address = get_router_ip() if has_shared_folder() else get_wsl_ip_address()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ip_address = get_router_ip() if has_shared_folder() else get_wsl_ip_address()
ip_address = get_router_ip() if has_shared_folder() else get_wsl_host_ip()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure the purpose of the function controller_ip_address. In mirrored mode, the return value of get_wsl_host_ip is fixed as 127.0.0.42

return ip_address


def controller_url_prefix(port='1234'):
if has_shared_folder() or is_wsl():
return 'tcp://' + (get_host_ip() if has_shared_folder() else get_wsl_ip_address()) + ':' + port + '/'
return 'tcp://' + (get_router_ip() if has_shared_folder() else get_wsl_ip_address()) + ':' + port + '/'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return 'tcp://' + (get_router_ip() if has_shared_folder() else get_wsl_ip_address()) + ':' + port + '/'
return 'tcp://' + (get_router_ip() if has_shared_folder() else get_wsl_host_ip()) + ':' + port + '/'

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but get_wsl_ip_address shoud be used here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You renamed this get_wsl_ip_address function to get_wsl_host_ip.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the file /etc/resolv.conf exist, the function get_wsl_host_ip never return 127.0.0.1 whatever the mode.
But get_wsl_ip_address can return get_wsl_host_ip or localhost

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean here is that in this PR, get_wsl_ip_address doesn't exist any more. You renamed it to get_wsl_host_ip. So, the above line will fail due to an attempt to call an unknown function.

webots_ros2_driver/webots_ros2_driver/utils.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants